from goods_info.models import *
from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
class  UnitsSerializer(ModelSerializer):

    '''

    商品列表的序列化类
    '''
    combine_units=serializers.SerializerMethodField(read_only=True)


    class Meta:
        model=UnitsModel
        fields='__all__'

    #将父类别下子类别也返回，传递的是树形json格式
    def get_combine_units(self,obj):
        return str(obj)
